import {Data} from "../axdr/Data";
import {dataKey} from "../bean/FrameData";
import {DataUtils} from "../DataUtils";
import {Enum} from "../axdr/Enum";
import {TI} from "../axdr/TI";
import {MS} from "../axdr/MS";


export function parseData(data: Data): String {
    let map = new Map();
    let frameData;
    switch (data.getChoiceIndex()) {
        case 0:
            map.set(dataKey.null_data, "");
            frameData = convertTSMapToJSObj(map);
            break;
        case 1:
            data.array.encodeAndSave(1000);
            let list_array = new Array<String>();
            for (let i = 0; i < data.array.size(); i++) {
                list_array.push(parseData(data.array.get(i)));
            }
            map.set(dataKey.array, list_array);
            frameData = convertTSMapToJSObj(map);
            break;
        case 2:
            data.structure.encodeAndSave(1000);
            let list_structure = new Array<String>();
            for (let i = 0; i < data.structure.size(); i++) {
                list_structure.push(parseData(data.structure.get(i)));
            }
            map.set(dataKey.structure, list_structure);
            frameData = convertTSMapToJSObj(map);
            break;
        case 3:
            data.bool.encodeAndSave(1000);
            map.set(dataKey.bool, DataUtils.bytesToHexString(data.bool.dataCode, 0, data.bool.dataCode.length));
            frameData = convertTSMapToJSObj(map);
            break;
        case 4:
            map.set(dataKey.bit_string, data.bit_string.toString());
            frameData = convertTSMapToJSObj(map);
            break;
        case 5:
            data.double_long.encodeAndSave(1000);
            map.set(dataKey.double_long, DataUtils.bytesToHexString(data.double_long.dataCode, 0, data.double_long.dataCode.length));
            frameData = convertTSMapToJSObj(map);
            break;
        case 6:
            data.double_long_unsigned.encodeAndSave(1000);
            map.set(dataKey.double_long_unsigned, DataUtils.bytesToHexString(data.double_long_unsigned.dataCode, 0, data.double_long_unsigned.dataCode.length));
            frameData = convertTSMapToJSObj(map);
            break;
        case 9:
            map.set(dataKey.octet_string, data.octet_string.toString());
            frameData = convertTSMapToJSObj(map);
            break;
        case 10:
            map.set(dataKey.visible_string, data.visible_string.toString());
            frameData = convertTSMapToJSObj(map);
            break;
        case 12:
            map.set(dataKey.utf8_string, data.utf8_string.toString());
            frameData = convertTSMapToJSObj(map);
            break;
        case 15:
            data.integer.encodeAndSave(1000);
            map.set(dataKey.integer, DataUtils.bytesToHexString(data.integer.dataCode, 0, data.integer.dataCode.length));
            frameData = convertTSMapToJSObj(map);
            break;
        case 16:
            data.longdata.encodeAndSave(1000);
            map.set(dataKey.long, DataUtils.bytesToHexString(data.longdata.dataCode, 0, data.longdata.dataCode.length));
            frameData = convertTSMapToJSObj(map);
            break;
        case 17:
            data.unsigned.encodeAndSave(1000);
            map.set(dataKey.unsigned, DataUtils.bytesToHexString(data.unsigned.dataCode, 0, data.unsigned.dataCode.length));
            frameData = convertTSMapToJSObj(map);
            break;
        case 18:
            data.long_unsigned.encodeAndSave(1000);
            map.set(dataKey.long_unsigned, DataUtils.bytesToHexString(data.long_unsigned.dataCode, 0, data.long_unsigned.dataCode.length));
            frameData = convertTSMapToJSObj(map);
            break;
        case 20:
            data.long64.encodeAndSave(1000);
            map.set(dataKey.long64, DataUtils.bytesToHexString(data.long64.dataCode, 0, data.long64.dataCode.length));
            frameData = convertTSMapToJSObj(map);
            break;
        case 21:
            data.long64_unsigned.encodeAndSave(1000);
            map.set(dataKey.long64_unsigned, DataUtils.bytesToHexString(data.long64_unsigned.dataCode, 0, data.long64_unsigned.dataCode.length));
            frameData = convertTSMapToJSObj(map);
            break;
        case 22:
            data.enumdata.encodeAndSave(1000);
            map.set(dataKey.enum_key, DataUtils.bytesToHexString(data.enumdata.dataCode, 0, data.enumdata.dataCode.length));
            frameData = convertTSMapToJSObj(map);
            break;
        case 23:
            map.set(dataKey.float32, data.float32.toString());
            frameData = convertTSMapToJSObj(map);
            break;
        case 24:
            map.set(dataKey.float64, data.float64.toString());
            frameData = convertTSMapToJSObj(map);
            break;
        case 25:
            data.date_time.encodeAndSave(1000);
            map.set(dataKey.date_time, DataUtils.bytesToHexString(data.date_time.dataCode, 0, data.date_time.dataCode.length));
            frameData = convertTSMapToJSObj(map);
            break;
        case 26:
            data.date.encodeAndSave(1000);
            map.set(dataKey.date, DataUtils.bytesToHexString(data.date.dataCode, 0, data.date.dataCode.length));
            frameData = convertTSMapToJSObj(map);
            break;
        case 27:
            data.time.encodeAndSave(1000);
            map.set(dataKey.time, DataUtils.bytesToHexString(data.time.dataCode, 0, data.time.dataCode.length))
            frameData = convertTSMapToJSObj(map);
            break;
        case 28:
            data.date_time_s.encodeAndSave(1000);
            map.set(dataKey.date_time_s, DataUtils.bytesToHexString(data.date_time_s.dataCode, 0, data.date_time_s.dataCode.length));
            frameData = convertTSMapToJSObj(map);
            break;
        case 80:
            data.oi.encodeAndSave(1000);
            map.set(dataKey.oi, DataUtils.bytesToHexString(data.oi.dataCode, 0, data.oi.dataCode.length));
            frameData = convertTSMapToJSObj(map);
            break;
        case 81:
            data.oad.encodeAndSave(1000);
            map.set(dataKey.oad, DataUtils.bytesToHexString(data.oad.dataCode, 0, data.oad.dataCode.length));
            frameData = convertTSMapToJSObj(map);
            break;
        case 82:
            data.road.encodeAndSave(1000);
            let road_data = {
                OAD: {},
                seq_oad: {},
            };
            let seq_oad = new Array<String>();
            for (let i = 0; i < data.road.oads.size(); i++) {
                let value = new Data();
                value.set_oad(data.road.oads.get(i));
                seq_oad.push(parseData(value));
            }
            data.road.oad.encodeAndSave(1000);
            road_data.OAD = DataUtils.bytesToHexString(data.road.oad.dataCode, 0, data.road.oad.dataCode.length);
            road_data.seq_oad = seq_oad;
            map.set(dataKey.road, road_data);
            frameData = convertTSMapToJSObj(map);
            break;
        case 83:
            data.omd.encodeAndSave(1000);
            map.set(dataKey.omd, DataUtils.bytesToHexString(data.omd.dataCode, 0, data.omd.dataCode.length));
            frameData = convertTSMapToJSObj(map);
            break;
        case 84:
            data.ti.encodeAndSave(1000);
            data.ti.unit.encodeAndSave(1000);
            data.ti.inter.encodeAndSave(1000);
            let ti_data = {
                enum: {},
                long_unsigned: {},
            }
            ti_data.enum = DataUtils.bytesToHexString(data.ti.unit.dataCode, 0, data.ti.unit.dataCode.length);
            ti_data.long_unsigned = DataUtils.bytesToHexString(data.ti.inter.dataCode, 0, data.ti.inter.dataCode.length);
            map.set(dataKey.ti, ti_data);
            frameData = convertTSMapToJSObj(map);
            break;
        case 85:
            map.set(dataKey.tsa, data.tsa.toString());
            frameData = convertTSMapToJSObj(map);
            break;
        case 86:
            map.set(dataKey.mac, data.mac.toString());
            frameData = convertTSMapToJSObj(map);
            break;
        case 87:
            map.set(dataKey.rn, data.rn.toString());
            frameData = convertTSMapToJSObj(map);
            break;
        case 88:
            data.region.encodeAndSave(1000);
            let region_data = {
                type: {},
                s_data: {},
                e_data: {}
            }
            let regionType = new Data();
            let enum_data = new Enum();
            data.region.unit.encodeAndSave(1000);
            enum_data.set_dataCode(data.region.unit.dataCode);
            regionType.set_enumData(enum_data);
            region_data.type = parseData(regionType);
            region_data.s_data = parseData(data.region.sval);
            region_data.e_data = parseData(data.region.eval);
            map.set(dataKey.region, region_data);
            frameData = convertTSMapToJSObj(map);
            break;
        case 89:
            data.scaler_unit.encodeAndSave(1000);
            map.set(dataKey.scaler_unit, DataUtils.bytesToHexString(data.scaler_unit.dataCode, 0, data.scaler_unit.dataCode.length));
            frameData = convertTSMapToJSObj(map);
            break;
        case 90:
            data.rsd.encodeAndSave(1000);
            let rsdTempData;
            switch (data.rsd.getChoiceIndex()) {
                case 0:
                    let selector0 = {}
                    rsdTempData = selector0;
                    break;
                case 1:
                    data.rsd.s1.encodeAndSave(1000);
                    let selector1 = {
                        OAD: {},
                        data: {},
                    }
                    data.rsd.s1.oad.encodeAndSave(1000);
                    data.rsd.s1.data.encodeAndSave(1000);
                    selector1.OAD = DataUtils.bytesToHexString(data.rsd.s1.oad.dataCode, 0, data.rsd.s1.oad.dataCode.length);
                    selector1.data = parseData(data.rsd.s1.data);
                    rsdTempData = selector1;
                    break;
                case 2:
                    data.rsd.s2.encodeAndSave(1000);
                    let selector2 = {
                        OAD: {},
                        s_data: {},
                        e_data: {},
                        unit: {},
                    }
                    data.rsd.s2.oad.encodeAndSave(1000);
                    data.rsd.s2.sval.encodeAndSave(1000);
                    data.rsd.s2.eval.encodeAndSave(1000);
                    data.rsd.s2.inter.encodeAndSave(1000);
                    selector2.OAD = DataUtils.bytesToHexString(data.rsd.s2.oad.dataCode, 0, data.rsd.s2.oad.dataCode.length);
                    selector2.s_data = parseData(data.rsd.s2.sval);
                    selector2.e_data = parseData(data.rsd.s2.eval);
                    selector2.unit = parseData(data.rsd.s2.inter);
                    rsdTempData = selector2;
                    break;
                case 3:
                    data.rsd.s3.encodeAndSave(1000);
                    let s3_list = new Array<any>();
                    let selector3 = {
                        seq_selector2: {},
                    }
                    for (let i = 0; i < data.rsd.s3.size(); i++) {
                        let selector2 = {
                            OAD: {},
                            s_data: {},
                            e_data: {},
                            unit: {},
                        }
                        data.rsd.s3.get(i).oad.encodeAndSave(1000);
                        data.rsd.s3.get(i).sval.encodeAndSave(1000);
                        data.rsd.s3.get(i).eval.encodeAndSave(1000);
                        data.rsd.s3.get(i).inter.encodeAndSave(1000);
                        selector2.OAD = DataUtils.bytesToHexString(data.rsd.s3.get(i).oad.dataCode, 0, data.rsd.s3.get(i).oad.dataCode.length);
                        selector2.s_data = parseData(data.rsd.s3.get(i).sval);
                        selector2.e_data = parseData(data.rsd.s3.get(i).eval);
                        selector2.unit = parseData(data.rsd.s3.get(i).inter);
                        s3_list.push(selector2);
                    }
                    selector3.seq_selector2 = s3_list;
                    rsdTempData = selector3;
                    break;
                case 4:
                    data.rsd.s4.encodeAndSave(1000);
                    let selector4 = {
                        date_time_s: {},
                        MS: {},
                    }
                    data.rsd.s4.dts.encodeAndSave(1000);
                    data.rsd.s4.ms.encodeAndSave(1000);
                    selector4.date_time_s = DataUtils.bytesToHexString(data.rsd.s4.dts.dataCode, 0, data.rsd.s4.dts.dataCode.length);
                    let s4_data_ms = new Data();
                    s4_data_ms.set_ms(data.rsd.s4.ms);
                    selector4.MS = parseMsData(data.rsd.s4.ms);
                    rsdTempData = selector4;
                    break;
                case 5:
                    data.rsd.s5.encodeAndSave(1000);
                    let selector5 = {
                        date_time_s: {},
                        ms: {},
                    }
                    data.rsd.s5.dts.encodeAndSave(1000);
                    data.rsd.s5.ms.encodeAndSave(1000);
                    selector5.date_time_s = DataUtils.bytesToHexString(data.rsd.s5.dts.dataCode, 0, data.rsd.s5.dts.dataCode.length);
                    selector5.ms = parseMsData(data.rsd.s5.ms);
                    rsdTempData = selector5;
                    break;
                case 6:
                    data.rsd.s6.encodeAndSave(1000);
                    let selector6 = {
                        s_time: {},
                        e_time: {},
                        ti: {},
                        ms: {},
                    }
                    data.rsd.s6.dtss.encodeAndSave(1000);
                    data.rsd.s6.dtse.encodeAndSave(1000);
                    data.rsd.s6.inter.encodeAndSave(1000);
                    data.rsd.s6.ms.encodeAndSave(1000);
                    let s6_inter = new Data();
                    s6_inter.set_ti(data.rsd.s6.inter);
                    selector6.s_time = DataUtils.bytesToHexString(data.rsd.s6.dtss.dataCode, 0, data.rsd.s6.dtss.dataCode.length);
                    selector6.e_time = DataUtils.bytesToHexString(data.rsd.s6.dtse.dataCode, 0, data.rsd.s6.dtse.dataCode.length);
                    selector6.ti = parseTIData(data.rsd.s6.inter);
                    selector6.ms = parseMsData(data.rsd.s6.ms);
                    rsdTempData = selector6;
                    break;
                case 7:
                    data.rsd.s7.encodeAndSave(1000);
                    let selector7 = {
                        s_time: {},
                        e_time: {},
                        ti: {},
                        ms: {},
                    }
                    data.rsd.s7.dtss.encodeAndSave(1000);
                    data.rsd.s7.dtse.encodeAndSave(1000);
                    data.rsd.s7.inter.encodeAndSave(1000);
                    data.rsd.s7.ms.encodeAndSave(1000);
                    selector7.s_time = DataUtils.bytesToHexString(data.rsd.s7.dtss.dataCode, 0, data.rsd.s7.dtss.dataCode.length);
                    selector7.e_time = DataUtils.bytesToHexString(data.rsd.s7.dtse.dataCode, 0, data.rsd.s7.dtse.dataCode.length);
                    selector7.ti = parseTIData(data.rsd.s7.inter);
                    selector7.ms = parseMsData(data.rsd.s7.ms);
                    rsdTempData = selector7;
                    break;
                case 8:
                    data.rsd.s8.encodeAndSave(1000);
                    let selector8 = {
                        s_time: {},
                        e_time: {},
                        ti: {},
                        ms: {},
                    }
                    data.rsd.s8.dtss.encodeAndSave(1000);
                    data.rsd.s8.dtse.encodeAndSave(1000);
                    data.rsd.s8.inter.encodeAndSave(1000);
                    data.rsd.s8.ms.encodeAndSave(1000);
                    selector8.s_time = DataUtils.bytesToHexString(data.rsd.s8.dtss.dataCode, 0, data.rsd.s8.dtss.dataCode.length);
                    selector8.e_time = DataUtils.bytesToHexString(data.rsd.s8.dtse.dataCode, 0, data.rsd.s8.dtse.dataCode.length);
                    selector8.ti = parseTIData(data.rsd.s8.inter);
                    selector8.ms = parseMsData(data.rsd.s8.ms);
                    rsdTempData = selector8;
                    break;
                case 9:
                    data.rsd.s9.encodeAndSave(1000);
                    data.rsd.s9.recn.encodeAndSave(1000);
                    let selector9 = {
                        n_times: {},
                    }
                    selector9.n_times = DataUtils.bytesToHexString(data.rsd.s9.recn.dataCode, 0, data.rsd.s9.recn.dataCode.length);
                    rsdTempData = selector9;
                    break;
                case 10:
                    data.rsd.s10.encodeAndSave(1000);
                    data.rsd.s10.ms.encodeAndSave(1000);
                    data.rsd.s10.recn.encodeAndSave(1000);
                    let selector10 = {
                        n_times: {},
                        ms: {},
                    }
                    selector10.n_times = DataUtils.bytesToHexString(data.rsd.s10.recn.dataCode, 0, data.rsd.s10.recn.dataCode.length);
                    selector10.ms = parseMsData(data.rsd.s10.ms);
                    rsdTempData = selector10;
                    break;
            }
            map.set(dataKey.rsd, rsdTempData);
            frameData = convertTSMapToJSObj(map);
            break;
        case 91:
            data.csd.encodeAndSave(1000);
            let tempData;
            switch (data.csd.getChoiceIndex()) {
                case 0:
                    let csdOadData = new Data();
                    csdOadData.set_oad(data.csd.oad);
                    tempData = parseData(csdOadData);
                    break;
                case 1:
                    let csdRoadData = new Data();
                    csdRoadData.set_road(data.csd.road);
                    tempData = parseData(csdRoadData);
                    break;
            }
            map.set(dataKey.csd, tempData);
            frameData = convertTSMapToJSObj(map);
            break;
        case 92:
            data.ms.encodeAndSave(1000);
            let msData;
            switch (data.ms.getChoiceIndex()) {
                case 0:
                case 1:
                    msData = "";
                    break;
                case 2:
                    let seqOfU = {
                        seq_unsigned: {},
                    }
                    let ms2_list = new Array<String>();
                    for (let i = 0; i < data.ms.groupmtype.size(); i++) {
                        let un8 = new Data();
                        un8.set_unsigned(data.ms.groupmtype.get(i));
                        ms2_list.push(parseData(un8));
                    }
                    seqOfU.seq_unsigned = ms2_list;
                    msData = seqOfU;
                    break;
                case 3:
                    let seqOfTsa = {
                        seq_tsa: {},
                    }
                    let m3_list = new Array<String>();
                    for (let i = 0; i < data.ms.groupmaddr.size(); i++) {
                        let tsa = new Data();
                        tsa.set_tsa(data.ms.groupmaddr.get(i));
                        m3_list.push(parseData(tsa));
                    }
                    seqOfTsa.seq_tsa = m3_list;
                    msData = seqOfTsa;
                    break;
                case 4:
                    let seqOfLu = {
                        seq_long_unsigned: {},
                    }
                    let m4_list = new Array<String>();
                    for (let i = 0; i < data.ms.groupsetindex.size(); i++) {
                        let lu = new Data();
                        lu.set_longUnsigned(data.ms.groupsetindex.get(i));
                        m4_list.push(parseData(lu));
                    }
                    seqOfLu.seq_long_unsigned = m4_list;
                    msData = seqOfLu;
                    break;
                case 5:
                    let seqOfR5 = {
                        seq_region: {},
                    }
                    let m5_list = new Array<String>();
                    for (let i = 0; i < data.ms.regiontype.size(); i++) {
                        let region = new Data();
                        region.set_region(data.ms.regiontype.get(i));
                        m5_list.push(parseData(region));
                    }
                    seqOfR5.seq_region = m5_list;
                    msData = seqOfR5;
                    break;
                case 6:
                    let seqOfR6 = {
                        seq_region: {},
                    }
                    let m6_list = new Array<String>();
                    for (let i = 0; i < data.ms.regionaddr.size(); i++) {
                        let region = new Data();
                        region.set_region(data.ms.regionaddr.get(i));
                        m6_list.push(parseData(region));
                    }
                    seqOfR6.seq_region = m6_list;
                    msData = seqOfR6;
                    break;
                case 7:
                    let seqOfR7 = {
                        seq_region: {},
                    }
                    let m7_list = new Array<String>();
                    for (let i = 0; i < data.ms.regionsetindex.size(); i++) {
                        let region = new Data();
                        region.set_region(data.ms.regionsetindex.get(i));
                        m7_list.push(parseData(region));
                    }
                    seqOfR7.seq_region = m7_list;
                    msData = seqOfR7;
                    break;
            }
            map.set(dataKey.ms, msData);
            frameData = convertTSMapToJSObj(map);
            break;
        case 93:
            data.sid.encodeAndSave(1000);
            data.sid.indi.encodeAndSave(1000);
            let sid_data = {
                double_long_unsigned: {},
                octet_string: {},
            }
            sid_data.double_long_unsigned = DataUtils.bytesToHexString(data.sid.indi.dataCode, 0, data.sid.indi.dataCode.length);
            sid_data.octet_string = data.sid.fdata.toString();
            map.set(dataKey.sid, sid_data);
            break;
        case 94:
            data.sid_mac.encodeAndSave(1000);
            data.sid_mac.sid.encodeAndSave(1000);
            data.sid_mac.sid.indi.encodeAndSave(1000);
            let sid_mac_data = {
                sid: {
                    double_long_unsigned: {},
                    octet_string: {},
                },
                mac: {},
            }
            sid_mac_data.sid.double_long_unsigned = DataUtils.bytesToHexString(data.sid_mac.sid.indi.dataCode, 0, data.sid_mac.sid.indi.dataCode.length);
            sid_mac_data.sid.octet_string = data.sid_mac.sid.fdata.toString();
            sid_mac_data.mac = data.sid_mac.mac.toString();
            map.set(dataKey.sid_mac, sid_mac_data);
            break;
        case 95:
            data.comdcb.encodeAndSave(1000);
            data.comdcb.baut.encodeAndSave(1000);
            data.comdcb.parity.encodeAndSave(1000);
            data.comdcb.datab.encodeAndSave(1000);
            data.comdcb.stopb.encodeAndSave(1000);
            data.comdcb.flow.encodeAndSave(1000);
            let comdcb_data = {
                baut: {},
                parity: {},
                datab: {},
                stopb: {},
                flow: {},
            }
            comdcb_data.baut = DataUtils.bytesToHexString(data.comdcb.baut.dataCode, 0, data.comdcb.baut.dataCode.length);
            comdcb_data.parity = DataUtils.bytesToHexString(data.comdcb.parity.dataCode, 0, data.comdcb.parity.dataCode.length);
            comdcb_data.datab = DataUtils.bytesToHexString(data.comdcb.parity.dataCode, 0, data.comdcb.parity.dataCode.length);
            comdcb_data.stopb = DataUtils.bytesToHexString(data.comdcb.stopb.dataCode, 0, data.comdcb.stopb.dataCode.length);
            comdcb_data.flow = DataUtils.bytesToHexString(data.comdcb.flow.dataCode, 0, data.comdcb.flow.dataCode.length);
            map.set(dataKey.comdcb, comdcb_data);
            break;
        case 96:
            data.rcsd.encodeAndSave(1000);
            let csd_list = new Array<any>();
            let rcsd_data = {
                seq_csd: {},
            }
            for (let i = 0; i < data.rcsd.size(); i++) {
                let tempData;
                switch (data.rcsd.get(i).getChoiceIndex()) {
                    case 0:
                        let csdOadData = new Data();
                        csdOadData.set_oad(data.rcsd.get(i).oad);
                        tempData = parseData(csdOadData);
                        break;
                    case 1:
                        let csdRoadData = new Data();
                        csdRoadData.set_road(data.rcsd.get(i).road);
                        tempData = parseData(csdRoadData);
                        break;
                }
                csd_list.push(tempData);
            }
            rcsd_data.seq_csd = csd_list;
            map.set(dataKey.rcsd, rcsd_data);
            break;
    }
    return frameData;
}

export function parseTIData(ti: TI): any {
    ti.unit.encodeAndSave(1000);
    ti.inter.encodeAndSave(1000);
    let ti_data = {
        enum: {},
        long_unsigned: {},
    }
    ti_data.enum = DataUtils.bytesToHexString(ti.unit.dataCode, 0, ti.unit.dataCode.length);
    ti_data.long_unsigned = DataUtils.bytesToHexString(ti.inter.dataCode, 0, ti.inter.dataCode.length);
    return ti_data;
}

export function parseMsData(ms: MS): any {
    let msData;
    switch (ms.getChoiceIndex()) {
        case 0:
        case 1:
            msData = "";
            break;
        case 2:
            let seqOfU = {
                seq_unsigned: {},
            }
            let ms2_list = new Array<String>();
            for (let i = 0; i < ms.groupmtype.size(); i++) {
                let un8 = new Data();
                un8.set_unsigned(ms.groupmtype.get(i));
                ms2_list.push(parseData(un8));
            }
            seqOfU.seq_unsigned = ms2_list;
            msData = seqOfU;
            break;
        case 3:
            let seqOfTsa = {
                seq_tsa: {},
            }
            let m3_list = new Array<String>();
            for (let i = 0; i < ms.groupmaddr.size(); i++) {
                let tsa = new Data();
                tsa.set_tsa(ms.groupmaddr.get(i));
                m3_list.push(parseData(tsa));
            }
            seqOfTsa.seq_tsa = m3_list;
            msData = seqOfTsa;
            break;
        case 4:
            let seqOfLu = {
                seq_long_unsigned: {},
            }
            let m4_list = new Array<String>();
            for (let i = 0; i < ms.groupsetindex.size(); i++) {
                let lu = new Data();
                lu.set_longUnsigned(ms.groupsetindex.get(i));
                m4_list.push(parseData(lu));
            }
            seqOfLu.seq_long_unsigned = m4_list;
            msData = seqOfLu;
            break;
        case 5:
            let seqOfR5 = {
                seq_region: {},
            }
            let m5_list = new Array<String>();
            for (let i = 0; i < ms.regiontype.size(); i++) {
                let region = new Data();
                region.set_region(ms.regiontype.get(i));
                m5_list.push(parseData(region));
            }
            seqOfR5.seq_region = m5_list;
            msData = seqOfR5;
            break;
        case 6:
            let seqOfR6 = {
                seq_region: {},
            }
            let m6_list = new Array<String>();
            for (let i = 0; i < ms.regionaddr.size(); i++) {
                let region = new Data();
                region.set_region(ms.regionaddr.get(i));
                m6_list.push(parseData(region));
            }
            seqOfR6.seq_region = m6_list;
            msData = seqOfR6;
            break;
        case 7:
            let seqOfR7 = {
                seq_region: {},
            }
            let m7_list = new Array<String>();
            for (let i = 0; i < ms.regionsetindex.size(); i++) {
                let region = new Data();
                region.set_region(ms.regionsetindex.get(i));
                m7_list.push(parseData(region));
            }
            seqOfR7.seq_region = m7_list;
            msData = seqOfR7;
            break;
    }
    return msData;
}

export function convertTSMapToJSObj(tsMap) {
    const jsObj = {};
    tsMap.forEach(function (value, key) {
        jsObj[key] = value;
    });
    return jsObj;
}
